package com.hontech.bv.ui

import android.os.Bundle
import android.view.MotionEvent
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.hontech.bv.utils.hideSoftKey

open class AutoHideKeyActivity : AppCompatActivity() {

    companion object {
        lateinit var INSTANCE: AppCompatActivity
            private set

        fun parentView(): View {
            return INSTANCE.window.decorView
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        INSTANCE = this
    }

    override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
        if (ev.action == MotionEvent.ACTION_DOWN) {
            hideSoftKey(this)
        }
        return super.dispatchTouchEvent(ev)
    }
}